<?php
require_once("../../connection.php"); 

$user = $_POST['user'];
$fbid = $_POST['fbid'];


$result = mysql_query("SELECT * FROM site_pms WHERE `type` LIKE '%$user%' GROUP BY `type`");
while($row = mysql_fetch_array($result))
{
	$type = $row['type'];
	$arr = explode("_",$type);
	$one = $arr[1];
	$two = $arr[2];
	
	//echo $one.' '.$two;
	
	if($one == $user)
		$other_one = $two;
	else $other_one = $one;
	
	$res = mysql_query("SELECT * FROM site_user_meta WHERE `fbid`='$other_one'");
	$name = mysql_result($res, 0, 'name');
	
	if(($fbid!="") && ($fbid == $other_one))
	echo '<div style="background:#fdd;padding:5px;text-decoration:none" onclick=\'window.location="index.php?cat=msg&fbid='.$other_one.'";\'>'.$name.'</div>';
	else
	echo '<div style="padding:5px;text-decoration:none;border:none" class="a menu-item" onclick=\'window.location="index.php?cat=msg&fbid='.$other_one.'";\'>'.$name.'</div>';
}

if(mysql_numrows($result) == 0)
	echo "None yet!";
?>